const { commonApi } = require('../../utils/api/index.js')
Page({
  data: {
    shopInfo: {}
  },

  onLoad() {
    this.getShopInfo();
  },

  // 拨打电话
  makePhoneCall() {
    wx.makePhoneCall({
      phoneNumber: this.data.shopInfo.phone
    });
  },

  // 示例：从服务器获取店铺信息
  async getShopInfo() {
    try {
      const result = await commonApi.getStoreDetail();
      if (result.code === '0000') {
        this.setData({
          shopInfo: result.data
        });
      }else{
        wx.showToast({
          title: '获取店铺详情失败：'+ result.msg,
          icon: 'none'
        })
      }
    } catch (error) {
      console.error('获取店铺详情失败：', error)
      wx.showToast({
        title: '获取店铺详情失败',
        icon: 'none'
      })
    }
  }
});